# Maintainer: Tim Meusel <tim@bastelfreak.de>
# Contributor: farawayer <farwayer@gmail.com>

_gemname='colored2'
pkgname="ruby-${_gemname}"
pkgver=3.1.2
pkgrel=5
pkgdesc='Simple gem that adds various colour methods to String class'
arch=('any')
url='https://github.com/kigster/colored2'
license=('MIT')
makedepends=('ruby-rdoc')
checkdepends=('ruby-rspec')
depends=('ruby')
source=("${url}/archive/v${pkgver}/${pkgname}-v${pkgver}.tar.gz")
options=("!emptydirs")
sha512sums=('fa318c71e253ea5d55e31bf477f4296973fc30f5963a473465becb411c51b2ded5eaa4017d54c1a793332ef334b72c77498821c9a172dd6e2bd07d3c34326489')

prepare() {
  cd "${srcdir}/${_gemname}-${pkgver}"

  # update the gemspec to allow newer dependency versions
  sed --in-place 's|~>|>=|g' "${_gemname}.gemspec"

  # disable coverage reporting to the cloud
  sed --in-place '/codeclimate-test-reporter/d' "${_gemname}.gemspec"
  sed --in-place '/simplecov/Id' spec/spec_helper.rb
}

build() {
  cd "${srcdir}/${_gemname}-${pkgver}"
  gem build "${_gemname}.gemspec"
}

check() {
  cd "${srcdir}/${_gemname}-${pkgver}"
  rspec
}

package() {
  cd "${srcdir}/${_gemname}-${pkgver}"
  local _gemdir="$(gem env gemdir)"
  gem install --verbose --ignore-dependencies --no-user-install --install-dir "${pkgdir}/${_gemdir}" --bindir "${pkgdir}/usr/bin" "${_gemname}-${pkgver}.gem"

  install -Dm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}/"
  install -Dm 644 README.md -t "${pkgdir}/usr/share/doc/${pkgname}"

  rm -rf "${pkgdir}/${_gemdir}/cache"
}

# vim: ts=2 sw=2 et:
